package hsb.ruoyi.common.converter;

import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.Provider;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;

/**
 * @author 胡帅博
 * @date 2023/1/4 23:59
 */
@Provider
public class LocalDateParamConverter implements ParamConverter<LocalDate> {

    public static void main(String[] args) {
        LocalDate parse = LocalDate.parse("2022-3-25");
        System.out.println(parse);
    }

    public LocalDate fromString(String value){
        try {
         //   String x = LocalDate.parse(value).toString();
            return LocalDate.parse(value);
        } catch (DateTimeParseException e) {

        }
        return null;
    }

    public String toString(LocalDate value){
        return value.toString();
    }
}
